package com.jlkf.service.util;

import com.jlkf.pojo.User;
import com.jlkf.pojo.UserBrank;

public class CheckParams {

	//登录
	public static String checkUserLogin(User u){
		String result="";
		if(u==null){
			result=LanguageUtils.returnLan(2, "list_empty");//默认使用英文
		}else if(StringTools.isEmpty(u.getPassword())){
			result=LanguageUtils.returnLan(u.getLanguage(), "password_empty");
		}else if(u.getPassword().length()<8||u.getPassword().length()>18){
			result=LanguageUtils.returnLan(u.getLanguage(), "password_length");
		}
		return result;
	}
	//编辑信息
	public static String checkUserUpdate(User u){
		String result="";
		/**
		 * else if(!StringTools.isEmpty(u.getName())&&u.getName().length()>16){//
			result=LanguageUtils.returnLan(u.getLanguage(), "userName_length");
		}else if(!StringTools.isEmpty(u.getFirstName())&&u.getFirstName().length()>16){//
			result=LanguageUtils.returnLan(u.getLanguage(), "userName_length");
		}else if(!StringTools.isEmpty(u.getMiddleName())&&u.getMiddleName().length()>16){//
			result=LanguageUtils.returnLan(u.getLanguage(), "userName_length");
		}else if(StringTools.isEmpty(u.getEmail())){//
			result=LanguageUtils.returnLan(u.getLanguage(), "email_empty");
		}
		 */
		if(u==null){
			result=LanguageUtils.returnLan(2, "list_empty");//默认使用英文
		}else if(!StringTools.isEmpty(u.getEmail())&&u.getEmail().length()>25){//
			result=LanguageUtils.returnLan(u.getLanguage(), "email_length");
		}else if(!StringTools.isEmpty(u.getEmail())&&!RegexUtil.isEmail(u.getEmail())){
			result=LanguageUtils.returnLan(u.getLanguage(), "email_format");
		}else if(!StringTools.isEmpty(u.getCompany())&&u.getCompany().length()>75){//
			result=LanguageUtils.returnLan(u.getLanguage(), "company_length");
		}else if(!StringTools.isEmpty(u.getAddress())&&u.getAddress().length()>75){//
			result=LanguageUtils.returnLan(u.getLanguage(), "address_length");
		}else if(!StringTools.isEmpty(u.getPostcode())&&u.getPostcode().length()>75){//
			result=LanguageUtils.returnLan(u.getLanguage(), "postcode_length");
		}else if(!StringTools.isEmpty(u.getPassword())&&(u.getPassword().length()>18||u.getPassword().length()<8)){//字母和数字8-18个字符
			result=LanguageUtils.returnLan(u.getLanguage(), "password_length");
		}
		return result;
	}
	//检查添加银行卡
	public static String checkUserBrank(UserBrank u){
		String result="";
		if(u==null){
			result=LanguageUtils.returnLan(2, "list_empty");//默认使用英文
		}else if(StringTools.isEmpty(u.getUbBrankNo())){
			result=LanguageUtils.returnLan(u.getLanguage(), "brankNo_empty");
		}else if(StringTools.isEmpty(u.getAfterThree())){//
			result=LanguageUtils.returnLan(u.getLanguage(), "back_three_empty");
		}else if(StringTools.isEmpty(u.getExpirationTime())){//
			result=LanguageUtils.returnLan(u.getLanguage(), "expirationTime_empty");
		}
		return result;
	}
}
